﻿import QtQuick 2.0
import QtQuick.Window 2.2
import "../../js/UI.js" as Style
import "../common"
import QtQuick.Controls 1.4
import QtQuick.Controls.Styles 1.0
BaseDialog{
    objectName: "sureORcancel"
   // signal sureORcancel(var index,var password);
    signal closepage()
    signal trigger(var password)
    property bool m_visible: Qt.inputMethod.visible
    property var m_height: Keyboard.keyboardRectangle.height
    onM_visibleChanged: {
        console.log(Qt.inputMethod.visible)
    }
    onM_heightChanged: {
        console.log(m_height)
        if(m_height>0){
            upAnimation.to = m_height
            upAnimation.start();
        }else{
            upAnimation.to = (parent.height-inputbox.height)*0.5
            upAnimation.start();
        }
    }
    MouseArea{
        anchors.fill: parent
        onClicked: {

        }
    }
    NumberAnimation {
        id: upAnimation
        target: inputbox
        duration: 5
        from: 0
        properties: "anchors.bottomMargin"
        onStopped: {

        }
    }

    Rectangle{
        z:10
        id:inputbox
        width: is_PCScreen ?  height*1.5 :  m_root_id.width - (Style.LeftScale + Style.RightScale) * 4 * m_lineValue
        height: 3.6 * m_lineValue + 4
        radius: m_lineValue*0.2
        anchors.bottom:parent.bottom
        anchors.bottomMargin: (parent.height-height)*0.5
        anchors.horizontalCenter: parent.horizontalCenter
        color: "white"
        Rectangle{
            width: parent.width*0.8
            height: parent.height*0.68
            anchors.left: parent.left
            anchors.leftMargin: 0.1*parent.width
            Column{
                width: parent.width
                height: childrenRect.height
                anchors.top:parent.top
                anchors.topMargin: 0.35*m_lineValue
                spacing: 0.35*m_lineValue
                Item{
                    width: parent.width
                    height: childrenRect.height
                    AText{
                        text:qsTr("%1").arg("请输入密码")
                        font.pointSize: 18
                        wrapMode:Text.WordWrap
                        anchors.centerIn: parent
                    }
                }
                Item{
                    width: parent.width
                    height: childrenRect.height
                    TextField {
                        id: m_firstEdit_id
                        width: parent.width*0.95
                        height: m_lineValue*0.7
                        anchors.centerIn: parent
                        font.pixelSize: Style.fontlittlcontent
                        font.family: Style.fontfamily
                        echoMode:TextInput.Password
                        style: TextFieldStyle {
                            placeholderTextColor: Style.textcolor
                            textColor: Style.fonttilteColor
                            font{pixelSize: Style.fontlittlcontent}
                            background: Rectangle {
                                border.width: 1
                                border.color: Style.bordercolor
                                color: Style.backgroundcolor
                                radius:Style.LoginJSTItemScale
                            }
                        }
                    }
                }
            }
        }
        RadiusBotton{
            id:sureTr
            width: parent.width*0.5
            height:0.32 * parent.height
            anchors.bottom: parent.bottom
            anchors.left: parent.left
            m_text: "确定"
            btnEnable: false
            onCanvasClicked:{
                trigger(m_firstEdit_id.text)
                m_firstEdit_id.text= ""
            }
        }
        RadiusBotton{
            width: parent.width*0.5
            height:0.32 * parent.height
            anchors.bottom: parent.bottom
            anchors.right: parent.right
            m_text: "取消"
            btnEnable: true
            onCanvasClicked:{
                closepage()
            }
        }
        SplitLine{
            width: parent.width
            anchors.top: sureTr.top
            anchors.left: parent.left
        }
        Vertical_Line{
            height: sureTr.height
            anchors.horizontalCenter: parent.horizontalCenter
            anchors.bottom: parent.bottom
        }
    }

}

